package zuoye5;

public class StudentBiz {
	Student[] students = new Student[2];
	
	public void add(Student s) throws StudentCountTooMuchException{
		boolean isHaveNull = false;
		
		for (int i = 0; i <students.length; i++) {
			if(students[i]==null){
				isHaveNull = true;
				students[i] = s;
				break;
			}
		}
		
		if(!isHaveNull){
			throw new StudentCountTooMuchException();
		}
	}
	
	public void show(){
		for (int i = 0; i < students.length; i++) {
			if(students[i]!=null){
				System.out.println(students[i]);
			}
		}
	}
	
	public static void main(String[] args) {
		StudentBiz sb = new StudentBiz();
		
		Student s1 = new Student("zhangsan",13,1.73);
		Student s2 = new Student("lisi",14,1.74);
		Student s3 = new Student("wangwu",15,1.75);
		
		
		try {
			sb.add(s1);
			sb.add(s2);
			sb.add(s3);
			
		} catch (StudentCountTooMuchException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		sb.show();
	}
}